package _022_2_15

func minCostClimbingStairs(cost []int) int {
	arr := make([]int, len(cost)+1)

	for i := 2; i < len(arr); i++ {
		if arr[i-1]+cost[i-1] > arr[i-2]+cost[i-2] {
			arr[i] = cost[i-2] + arr[i-2]
		} else {
			arr[i] = cost[i-1] + arr[i-1]
		}
	}

	return arr[len(arr)-1]
}
